import logging as log
import streamlit as st
from attr import dataclass
from utils.file_util import(get_api_key,
                            get_toml_config_file)

@dataclass(frozen=True)
class AgentConfig:
    gemini:dict[str,str]
    streamlit:dict[str,str]


@st.cache_data
def get_agent_config(config_file:str):
    config = get_toml_config_file(config_file)
    gemini = config["gemini"]
    api_key = get_api_key(key=gemini["api_key_name"])
    gemini.update({"api_key":api_key})

    config = AgentConfig(gemini=config["gemini"],
                streamlit=config["streamlit"])
    log.info(f"读取配置信息：{config}")
    return config